'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const jwt = app.middleware.jwt({ app });
  const { router, controller } = app;

  router.group({ name: "layout", prefix: "/layout" }, (router) => {
    let { add, show } = controller.layout;
    router.post("/add", add);
    router.get("/show", show);
  });



  router.group({ name: "component", prefix: "/component" }, (router) => {
    let { update, list } = controller.component;
    router.post("/update", jwt, update);
    router.get("/list", jwt, list);
  });


  router.group({ name: "user", prefix: "/user" }, (router) => {
    let { login, register, verify, info } = controller.user;
    router.post("/register", register);
    router.post("/login", login);
    router.get("/verify", verify);
    router.get("/info", jwt, info);
  });


  // 验证码
  router.get("/captcha", controller.util.captcha);
  router.get("/sendcode", controller.util.sendEmailCode);
};
